﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class BalanceCenter_AdminSetSurrogate : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        RequestCompetences = Competences.BuildCompetencesList(Competences.Administrator);
        RequestLoginPage = "BalanceCenter/AdminSetSurrogate.aspx";

        base.OnInit(e);
    }

    #endregion

    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (tbUserName.Text == "")
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, "请输入用户ID");

            return;
        }

        User tu = new User();
        tu.Name = tbUserName.Text.Trim();

        string ReturnDescription = "";
        if (tu.GetUserInfoByName(ref ReturnDescription) < 0)
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, ReturnDescription);

            return;
        }

        ShoveEL.Database.MSSQL.ExecuteNonQuery("update T_Users set isSurrogate=1 where [ID] = " + tu.ID.ToString());
        ShoveEL.Database.MSSQL.ExecuteNonQuery("insert into T_TryForSurrogate (UserID, DealResult) Values (" + tu.ID.ToString() + ", 1)");

        tbUserName.Text = "";

        ShoveEL._Web.JavaScript.Alert(this.Page, "设置成功");

        return;
    }
}
